package org.test.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.iconic.richtexteditor.IStyledTextWidgetImageCreator;
import com.iconic.richtexteditor.RichTextEditorWidgetBasicImageCreator;
import com.iconic.richtexteditor.RichTextEditorWidgetFeatureSet;
import com.iconic.richtexteditor.html.HTMLTextEditorWidget;
import com.iconic.richtexteditor.html.HTMLTextModel;


public class PeerGUI {
	public static void main(String[] args) {
		Display display = new Display();
	    Shell shell = new Shell(display);
	    
	    shell.setText("iTalk");
	    Rectangle screen = shell.getDisplay().getClientArea();
	    int screenHeigth = screen.height;
	    int screenWidth  = screen.width;
	    
	    shell.setSize(300, screenHeigth - 20);
	    shell.setLocation(screenWidth - 300, 0);
	    FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
	    fillLayout.marginHeight = 5;
	    fillLayout.marginWidth = 5;
	    fillLayout.spacing = 1;  
	    
	    shell.setLayout(fillLayout);

	    /*Label titleLabel = new Label(shell, SWT.NONE);
        titleLabel.setBackground(shell.getBackground());
        titleLabel.setForeground(shell.getForeground());
        titleLabel.setText("i am label");*/
        
        /*Button pushButton = new Button(shell,SWT.PUSH);
        pushButton.setText("button");*/
        
        final String menuHeaderName = "Edit";
        final boolean preventTypingOfHTMLTags = true;
        final int compositeStyle = SWT.BORDER;
        final int toolBarStyle = SWT.NULL;
        final int styledTextStyle = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP;

        RichTextEditorWidgetFeatureSet featureSet = RichTextEditorWidgetFeatureSet.ALL_FEATURES;
        IStyledTextWidgetImageCreator imageCreator = new RichTextEditorWidgetBasicImageCreator(
        		"", false);
        //IStyledTextWidgetImageCreator imageCreator = new RichTextEditorWidgetBasicImageCreator();
        
        Button toogleButton  = new Button(shell ,SWT.TOGGLE);
        toogleButton.setText("toogle");
        HTMLTextEditorWidget htmlTextEditorWidget = new HTMLTextEditorWidget(
        		featureSet,
        		imageCreator,
        		shell,
        		menuHeaderName,
        		preventTypingOfHTMLTags,
        		compositeStyle,
        		toolBarStyle,
        		styledTextStyle);
        String htmlContent = "<b>asdasdhsdaih</b>";
		HTMLTextModel htmlTextModel = new HTMLTextModel(htmlContent );
        htmlTextEditorWidget.setFormattedText(htmlTextModel);
        
        shell.pack();
	    shell.open();
	    
	    // Set up the event loop.
	    while (!shell.isDisposed()) {
	      if (!display.readAndDispatch()) {
	        // If no more entries in event queue
	        display.sleep();
	      }
	    }

	    display.dispose();
	}
}
